package com.hp.easyBuy.controller;
/*
* 主页相关的请求
* */

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hp.easyBuy.entity.DTO.TGoodsCategoryDTO;
import com.hp.easyBuy.entity.TGoods;
import com.hp.easyBuy.entity.TNews;
import com.hp.easyBuy.service.CommentService;
import com.hp.easyBuy.service.GoodsService;
import com.hp.easyBuy.service.NewService;
import com.hp.easyBuy.utils.R;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("index")
public class IndexController {
    @Resource
    private GoodsService goodsService;

    @Resource
    private CommentService commentService;
    @Resource
    private NewService newService;

    @Resource
    private RedisTemplate redisTemplate;


    //    获取今日特价或者热卖推荐
    @RequestMapping("goodsList")
    @ResponseBody
    public R indexGoodList(Integer promotiontype) {
        Page<TGoods> page = goodsService.indexGoodList(promotiontype);
        return R.success(page);
    }

    //  获取商品的分类集合，每个2类商品为集合，存储下面的三类商品
    @RequestMapping("goodsLevel")
    @ResponseBody
    public R goodsLevelList() {

        List<TGoodsCategoryDTO> tGoodsCategoryList = goodsService.goodsLevelList();
        return R.success(tGoodsCategoryList);
    }

    @RequestMapping("newList")
    @ResponseBody
    public R indexNewList(Integer newstype) {
        Page<TNews> page = newService.indexNewList(newstype);
        return R.success(page);
    }
}
